/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ADT;
import Interfaces.Mass;

/**
 *
 * @author markusbaisch
 */
public class MassImpl extends Values implements Mass {

    private final double mass;

    // Konstruktor
    private MassImpl(double mass) {
        this.mass = mass;
    }

    @Override
    public Mass add(Mass Value) {
        return valueOf( mass + Value.kg() );
    }

    @Override
    public Mass sub(Mass Value) {
        return valueOf( mass - Value.kg() );
    }

    @Override
    public Mass mul(double faktor) {
        return valueOf( mass * faktor );
    }

    @Override
    public Mass div(double faktor) {
        return valueOf( mass / faktor );
    }

    @Override
    public double div(Mass Value) {
        return mass / Value.kg();
    }

    @Override
    public Mass inverse() {
        return new MassImpl(mass * -1.0);
    }

    @Override
    public boolean isZero() {
        return (mass == ZERO_MASS);
    }

    @Override
    public boolean isValid() {
        return true;
    }

    @Override
    public int compareTo(Mass Value) {
        return Double.compare( mass, Value.kg() );
    }

    //@Override
    public static Mass valueOf(double Value) {
        return new MassImpl( Value );
    }

    @Override
    public double getValue() {
        return mass;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) return true;
        if (!(o instanceof MassImpl)) return false;
        return this.compareTo((MassImpl) o) == 0;
    }

    @Override
    public int hashCode(){
        return hashDouble( mass );
    }

    @Override
    public double kg() {
        return mass;
    }

    @Override
    public double to() {
        return mass / KILO;
    }

}
